# 作者：SP
# 开发时间：2025/3/6 21:44
# 作者：SP
# 开发时间：2025/3/6 21:34
class Car:
    def __init__(self, make, model, year):
        self.make = make
        self.model = model
        self.year = year
        self.odometer_reading = 0  # 类属性的默认值

    def get_descriptive_name(self):
        print(f'{self.year} {self.model} {self.make}')

    def read_odometer(self):
        """打印汽车里程的消息"""
        print(f'This car has {self.odometer_reading} mail on it')

    def update_odometer(self,mileage):
        """将里程表读书设置为指定的值
        禁止将里程表读书往回调"""
        if mileage >= self.odometer_reading:
            self.odometer_reading = mileage
        else:
            print('里程数不允许回调')

    def increment_odometer(self,miles):
        '''将里程表读书增加指定的量'''
        self.odometer_reading += miles



my_new_car = Car('audi', 'A4', 2019)
#1.直接修改属性的值
my_new_car.odometer_reading = 25
print(my_new_car.read_odometer())

#2.通过方法修改属性的值
my_new_car.update_odometer(24)
my_new_car.read_odometer()

#3.通过方法对属性的值进行增量
my_new_car.increment_odometer(100)
my_new_car.read_odometer()